package com.situ.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Pagination {
    private int pageSize;
    private int pageNo;
    private long total;//总记录数
    private int pages;
    private Double totalMoney;
    public int getOffset(){
        return (pageNo - 1) * pageSize;
    }

    public Pagination(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    //行数
    public int getLimit(){
        return pageSize;
    }
    //总页数
    public int getPages(){
        pages=(int) Math.ceil(total * 1.0 / pageSize);
//        if (total*1.0/pageSize>0){
//            pages++;
//        }
        return pages;
    }
}
